<?php

namespace App\Transformers\Frontend;

use App\Models\Order\Item;
use League\Fractal\TransformerAbstract;

class OrderItemTransformer extends TransformerAbstract
{
    protected $availableIncludes = ['video'];

    public function transform(Item $model)
    {
        return $model->attributesToArray();
    }

    public function includeVideo(Item $model)
    {
        $video = $model->video;
        if (!$video){
            return $this->null();
        }
        return $this->item($video, new VideoTransformer());
    }
}